package com.lyf.scm.plan.domain.repository;


import cn.hutool.core.util.ReUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lyf.scm.common.enums.GmvTargetEnum;
import com.lyf.scm.common.enums.SalesPlanOtherDifferinEnum;
import com.lyf.scm.plan.api.dto.SalesPlanOtherDifferinDTO;
import com.lyf.scm.plan.api.dto.SalesPlanOtherDifferinInfoDTO;
import com.lyf.scm.plan.domain.convertor.SalesPlanOtherDifferinConvertor;
import com.lyf.scm.plan.domain.convertor.SalesPlanOtherDifferinSelectConvertor;
import com.lyf.scm.plan.insfrastructure.db.dataobject.SalesPlanOtherDifferinDO;
import com.lyf.scm.plan.insfrastructure.db.dataobject.SalesPlanSelectDO;
import com.lyf.scm.plan.insfrastructure.db.mapper.SalesPlanOtherDifferinMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * description:
 * 其他渠道计划_目标与销售计划差异资源库
 *
 * @author: huangtao
 * @data: 2020/7/31
 */
@Service
public class SalesPlanOtherDifferinRespository {

    @Resource
    private SalesPlanOtherDifferinConvertor salesPlanOtherDifferinConvertor;
    @Resource
    private SalesPlanOtherDifferinSelectConvertor salesPlanOtherDifferinSelectConvertor;
    @Resource
    private SalesPlanOtherDifferinMapper salesPlanOtherDifferinMapper;


    /**
     * 按条件其他渠道计划_目标与销售计划差异(周)
     * @param slaesPlanOtherDifferin
     * @return
     */
    public PageInfo<SalesPlanOtherDifferinDO> listWeekBySelective(SalesPlanOtherDifferinDTO slaesPlanOtherDifferin) {
        PageHelper.startPage(slaesPlanOtherDifferin.getPageNum(), slaesPlanOtherDifferin.getPageSize());
        SalesPlanSelectDO salesPlanSelectDO = salesPlanOtherDifferinSelectConvertor.dtoToDO(slaesPlanOtherDifferin);
        return new PageInfo(salesPlanOtherDifferinMapper.listWeekBySelective(salesPlanSelectDO));
    }

    public List<SalesPlanOtherDifferinDTO> listAllByCondition(SalesPlanOtherDifferinDTO slaesPlanOtherDifferin) {
        return salesPlanOtherDifferinConvertor.doToDTO(salesPlanOtherDifferinMapper.listAllByCondition(salesPlanOtherDifferinSelectConvertor.dtoToDO(slaesPlanOtherDifferin)));
    }


    /**
     * 查询全渠道gmv指标(范围)
     * @param salesPlanSelectDO
     * @return
     */
    public List<SalesPlanOtherDifferinDTO> listSalesAndTarget(SalesPlanOtherDifferinDO salesPlanOtherDifferinDO) {
        return salesPlanOtherDifferinConvertor.doToDTO(salesPlanOtherDifferinMapper.listSalesAndTarget(salesPlanOtherDifferinDO));
    }
    /**
     * 按条件查询其他渠道计划差异(周期)
     * @param slaesPlanOtherDifferin
     * @return
     */
    public List<SalesPlanOtherDifferinDTO> listAllByCycles(SalesPlanOtherDifferinDTO slaesPlanOtherDifferin) {
        return salesPlanOtherDifferinConvertor.doToDTO(salesPlanOtherDifferinMapper.listAllByCycles(salesPlanOtherDifferinSelectConvertor.dtoToDO(slaesPlanOtherDifferin)));
    }

    /**
     * 导出所有查询数据
     *
     * @param salesPlanOtherDifferinDTO
     * @return {@link List<SalesPlanOtherDifferinInfoDTO>}
     **/
    public List<SalesPlanOtherDifferinInfoDTO> searchedDataExport(SalesPlanOtherDifferinDTO salesPlanOtherDifferinDTO) {
        return  null;//salesPlanOtherDifferinMapper.listWeekBySelective(salesPlanOtherDifferinSelectConvertor.dtoToDO(salesPlanOtherDifferinDTO));
    }


    public void delete(String opSign){
        salesPlanOtherDifferinMapper.delete(opSign);
    }
    public void deleteByOpSign(String opSign) {
        salesPlanOtherDifferinMapper.deleteByOpSign(opSign);
    }
}
